package com.ayf.payment.game.api.utils;

import org.apache.commons.lang.StringUtils;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

public final class PwdUtil {

    // 密码至少8到30位，必须数字+字母
    private static final String pwd_input_reg="^(?=.*[A-Za-z])(?=.*\\d)[A-Za-z\\d]{8,30}$";
    public static final String pwd_input_reg_err_msg = "密码长度必须在8到30位之间，必须是数字+字母组合";

    private PwdUtil(){}
    private Pattern myPattern = Pattern.compile(pwd_input_reg);

    public boolean checkPwdInputNoPass(String inputPwd){
        return !checkPwdInputPass(inputPwd);
    }

    public boolean checkPwdInputPass(String inputPwd){
        if (StringUtils.isEmpty(inputPwd)){
            return false;
        }
        Matcher m =myPattern.matcher(inputPwd);
        return m.matches();
    }

     public static class init {
        public static final PwdUtil instance = new PwdUtil();
    }

    public static void main(String[] args) {
        System.out.println(PwdUtil.init.instance.checkPwdInputNoPass("12345678^"));
    }
}

